package entities;

import java.io.Serializable;

import javax.persistence.DiscriminatorValue;
import javax.persistence.Entity;
import javax.persistence.EnumType;
import javax.persistence.Enumerated;
import javax.persistence.FetchType;
import javax.persistence.ManyToOne;

import enums.PlayerEventType;

@Entity
@DiscriminatorValue("playerevent")
public class PlayerEvent extends Event implements Serializable {

	private static final long serialVersionUID = 1L;

    @ManyToOne(fetch=FetchType.EAGER)
	private Player player;
    
    @Enumerated(EnumType.STRING)
    private PlayerEventType typeEventPlayer;

	public Player getPlayer() {
		return player;
	}

	public void setPlayer(Player player) {
		this.player = player;
	}

	public PlayerEventType getTypeEventPlayer() {
		return typeEventPlayer;
	}

	public void setTypeEventPlayer(PlayerEventType typeEventPlayer) {
		this.typeEventPlayer = typeEventPlayer;
	}

	@Override
	public int hashCode() {
		final int prime = 31;
		int result = super.hashCode();
		result = prime * result + ((player == null) ? 0 : player.hashCode());
		return result;
	}

	@Override
	public boolean equals(Object obj) {
		if (this == obj)
			return true;
		if (!super.equals(obj))
			return false;
		if (getClass() != obj.getClass())
			return false;
		PlayerEvent other = (PlayerEvent) obj;
		if (player == null) {
			if (other.player != null)
				return false;
		} else if (!player.equals(other.player))
			return false;
		return true;
	}
}
